import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true }

  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/dashboard',
  //   name: 'Dashboard',
  //   hidden: true,
  //   children: [{
  //     path: 'dashboard',
  //     component: () => import('@/views/dashboard/index')
  //   }]
  // }

]
export const asyncRouterMap = [
  {
    // path: '/form',
    path: '/',
    redirect: '/form',
    component: Layout,
    pathAlias: '/form',
    icon: 'console',
    icon1: 'console1',
    children: [
      {
        path: 'form',
        name: 'Form',
        component: () => import('@/views/form/index'),
        meta: { title: '工作台', icon: 'console' }
      }
    ]
  }, {
    path: '/project',
    component: Layout,
    name: 'project',
    pathAlias: '/project/index',
    icon: 'project',
    icon1: 'project1',
    children: [
      {
        path: 'index',
        component: () => import('@/views/project/index'),
        name: 'Menu1-2-1',
        title: 'Menu1-2-1',
        meta: { title: '项目', icon: 'project' }
      }
    ]
  }, {
    path: '/task',
    component: Layout,
    pathAlias: '/task/index',
    icon: 'task',
    icon1: 'task1',
    children: [
      {
        path: 'index',
        component: () => import('@/views/task/index'),
        name: 'task',
        title: 'task',
        meta: { title: '任务', icon: 'task' }
      }
    ]
  }, {
    path: '/bug',
    component: Layout,
    pathAlias: '/bug/index',
    icon: 'bug',
    icon1: 'bug1',
    children: [
      {
        path: 'index',
        component: () => import('@/views/bug/index'),
        name: 'bug',
        title: 'bug',
        meta: { title: '缺陷', icon: 'bug' }
      }
    ]
  }, {
    path: '/document',
    component: Layout,
    pathAlias: '/document/index',
    icon: 'document',
    icon1: 'document1',
    children: [
      {
        path: 'index',
        component: () => import('@/views/document/index'),
        name: 'document',
        title: 'document1',
        meta: { title: '文档', icon: 'document' }
      }
    ]
  }, {
    path: '/set',
    component: Layout,
    pathAlias: '/set/index',
    icon: 'set',
    icon1: 'set1',
    children: [
      {
        path: 'index',
        component: () => import('@/views/set/index'),
        name: 'set',
        title: 'set',
        meta: { title: '设置', icon: 'set' }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
  // {
  //   id: 1,
  //   parentId: -1,
  //   path: '/example',
  //   component: Layout,
  //   redirect: '/example/table',
  //   name: 'Example',
  //   title: '基础数据',
  //   meta: { title: '基础数据', icon: 'example' }
  // }, {
  //   id: 2,
  //   parentId: -1,
  //   path: 'table',
  //   name: 'Table',
  //   title: '表格',
  //   component: () => import('@/views/table/index'),
  //   meta: { title: '表格', icon: 'workbench' }
  // }, {
  //   id: 2,
  //   parentId: -1,
  //   path: 'tree',
  //   name: 'Tree',
  //   title: '树形表格',
  //   component: () => import('@/views/tree/index'),
  //   meta: { title: '树形表格', icon: 'tree' }
  // }
]
export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
